package com.example.leetcode.demo.leetcode;

public class rotate {
    public static void main(String[] args) {
        int [] nums=new int[]{1,2,3,4,5,6,7};
        rotate(nums,3);
    }
    public static void rotate(int[] nums, int k) {
        int n=nums.length;
        int[] arr=new int[n];
        for(int i=0;i<n;i++){
            arr[(i+k)%n]=nums[i];
        }
        System.arraycopy(arr,0,nums,0,n);
        for(int a=0;a<n;a++){
            System.out.print(nums[a]);
        }
    }
    /*
    public static void rotate(int[] nums, int k) {
        for(int i=0;i<k;i++){
            int temp=nums[nums.length-1];
            for(int j=nums.length-1;j>0;j--){
                nums[j]=nums[j-1];
            }
            nums[0]=temp;
            for(int a=0;a<nums.length;a++){
                System.out.print(nums[a]);
            }
            System.out.println();
        }
    }
     */

}
